//
//  HNAudioEngine.m
//  HeroNuts
//
//  Created by Vicky on 6/4/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "HNAudioEngine.h"
#import "cocos2d.h"
#import "SimpleAudioEngine.h"

@implementation HNAudioEngine

static HNAudioEngine* sharedAudioEngine_ = nil;

#pragma mark HNAudioEngine - Alloc, Singleton

+ (id)alloc
{
	NSAssert(sharedAudioEngine_ == nil, @"Attempted to allocate a second instance of a singleton.");
	return [super alloc];
}

+ (id)sharedEngine
{
	if (!sharedAudioEngine_)
        sharedAudioEngine_ = [[HNAudioEngine alloc] init];
    
	return sharedAudioEngine_;
}

#pragma mark HNAudioEngine - Play sound effect

- (void)playSoundEffectWithActor:(NSString *)actor action:(NSString *)action
{
    NSString *filePath; 
    
	
    
    NSString* effectName = [NSString stringWithFormat:@"%@_%@.caf",actor,action];
    filePath = [[NSBundle mainBundle] pathForResource:effectName ofType:@""];
    
    if(filePath)
    [[SimpleAudioEngine sharedEngine] playEffect:effectName];
}


- (void)playSoundEffect:(NSString *)effect
{
    NSString *filePath; 
	
	NSString* effectName = [NSString stringWithFormat:@"%@.caf",effect];
    filePath = [[NSBundle mainBundle] pathForResource:effectName ofType:@""];
    
    if(filePath)
    [[SimpleAudioEngine sharedEngine] playEffect:effectName];
}

@end
